/*
Copyright (C) 2015 Pieter Staal

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef WATERGENERATOR_H
#define WATERGENERATOR_H

#include <vector>
#include <SFML/Graphics.hpp>
#include "river.h"

struct WaterSettings
{
    int size; //size of the heightmap
    double *heightmap;
    bool *landmap;
    double waterLevel;
};

class WaterGenerator
{
    public:
        WaterGenerator(WaterSettings WaterSettings);
        void setHeightmap(double *value) { heightmap = value; }
        void updateWaterMap(int iterations);
        double* getWatermap() { return displayWatermap; }
        void normalizeMap();
        void addRiver();
        void determineCoasts();
        void setLandmap(bool *value) { landmap = value; }
    protected:
    private:
        void flowWater();
        WaterSettings settings;
        double *heightmap;
        double *watermap;
        double *normalizedHeightmap;
        double *normalizedWatermap;
        double *displayWatermap;
        bool *landmap;
        std::vector<int> coastIndices;
        std::vector<River> rivers;
        int riverCoordMod = 3;
        double waterLevel;
};

#endif // WATERGENERATOR_H
